package com.ctshk.rpc.custom.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.custom.entity.CustomizedTripScheduleDate;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;

/**
 * <p>
 * 团期行程报价日期 Mapper 接口
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-01-21
 */
public interface CustomizedTripScheduleDateMapper extends BaseMapper<CustomizedTripScheduleDate> {

    /**
     * 改为已删除
     * @param scheduleId
     * @param userId
     * @return
     */
    @Update("UPDATE t_customized_trip_schedule_date \n" +
            "SET is_deleted = 1,modified_id = #{modified_id}\n" +
            "WHERE schedule_id = #{schedule_id}")
    Integer clearBySchedule(@Param("schedule_id") Long scheduleId,@Param("modified_id") Long userId);

    /**
     * 行程报价总单价
     * @param scheduleId
     * @return
     */
    @Select("SELECT SUM(total_amount/total_people)\n" +
            "FROM t_customized_trip_schedule_date \n" +
            "WHERE schedule_id = #{schedule_id} AND is_deleted = 0")
    BigDecimal sumSinglePrice(@Param("schedule_id") Long scheduleId);
}
